package com.my.kindlesend.enums;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 文件发送状态枚举类
 */
@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public enum FileSendStatusEnum {

    /**
     * 未发送
     */
    NOT_SENT(0, "未发送"),
    
    /**
     * 发送中
     */
    SENDING(1, "发送中"),

    /**
     * 发送成功
     */
    SENT_SUCCESS(2, "发送成功"),

    /**
     * 发送失败
     */
    SENT_FAILED(3, "发送失败");

    private final int code;
    private final String desc;

    /**
     * 根据状态码获取枚举值
     * @param code 状态码
     * @return 枚举值
     */
    public static FileSendStatusEnum getByCode(int code) {
        for (FileSendStatusEnum status : values()) {
            if (status.code == code) {
                return status;
            }
        }
        return NOT_SENT;
    }
}